package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.Exchange;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface ExchangeMapper {
    int deleteByPrimaryKey(String exchangeId);

    int insert(Exchange record);

    int insertSelective(Exchange record);

    Exchange selectByPrimaryKey(String exchangeId);

    int updateByPrimaryKeySelective(Exchange record);

    int updateByPrimaryKey(Exchange record);

    //换货申请的审核
    int auditExchange(@Param("auditUserId") String auditUserId, 
                      @Param("exchangeNumber") String exchangeNumber, 
                      @Param("isAudit") Integer isAudit);

    //更改换货订单的状态
    @Update("update c_exchange set exchange_status=#{status}, storage_user_id=#{userId} " +
            "where exchange_number=#{exchangeNumber}")
    int changeExchangeStatus(@Param("userId") String userId, 
                             @Param("exchangeNumber") String exchangeNumber, 
                             @Param("status") Integer status);

    //查询换货订单
    List<Map<String,Object>> getExchangeList(@Param("isAudit") Integer isAudit, 
                                             @Param("start") Integer start, 
                                             @Param("end") Integer size, 
                                             @Param("search") String search,
                                             @Param("shopId") String shopId,
                                             @Param("startTime") String startTime,
                                             @Param("endTime") String endTime);

    //查询换货订单的数量
    int getExchangeListAmount(@Param("isAudit") Integer isAudit, 
                              @Param("search") String search,
                              @Param("shopId") String shopId,
                              @Param("startTime") String startTime,
                              @Param("endTime") String endTime);

    //验证唯一
    List<Exchange> verSole(@Param("orderNumber")String orderNumber, @Param("goodsId")String goodsId);

    Exchange getExchangeByExchangeNumber(@Param("exchangeNumber") String exchangeNumber);
}